<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html lang="zh-CN">
	<head>
		<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE6">
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<meta name="Author" content="">
		<meta name="Keywords" content="">
		<meta name="Description" content="">
		<link rel="shortcut icon" href="<%=basePath%>favicon.ico" />
		<link rel="stylesheet" type="text/css" href="<%=basePath%>css/all_b.css?20161126">
		<script type="text/javascript" src="<%=basePath%>js/jquery.min.js?20161126"></script>
		<script type="text/javascript" src="<%=basePath%>js/layer/layer.js?20161126"></script>
		<title>代理- 用户列表</title>
	</head>
	<body style="" id="bodyModule">
		<jsp:include page="../commons/manage_head.jsp" flush="true"></jsp:include>
		<div id="layout" class="container" style="height: 666px;">
			<div style="display: block;" id="rightLoader" dom="right"
				class="main-content bet-content">
				<div id="memberList" class="page">
					<div class="title">
						<input maxlength="16" id="se_con" type="text" value="${userNo }" placeholder="请输入完整账户...">
						<a href="javascript:void(0)" id="search" class="mag-btn1">查询</a>
						<c:if test="${sessionUser.roleId==1||sessionUser.roleId==2}">
						<a href="<%=basePath%>user/add_user" id="add"
							class="mag-btn1 mag-btn2">新增</a>
						</c:if>
						<a href="javascript:history.go(-1)" id="reback" level="1"
							class="mag-btn1">返回</a>	
					</div>
					<table class="clear-table mag-list" id="memeber_tb">
						<thead>
							<tr>
								<th>
									编号
								</th>
								<th>
									名称
								</th>
								<th>
									账号
								</th>
								<th>
									信用额度
								</th>
								<th>
									账户余额
								</th>
								<c:if test="${roleId == 1 }">
									<th name="level_name" ln="5">
										整盘总额
									</th>
								</c:if>
								<th>
									今日输赢
								</th>
								<th name="level_name" ln="4">
									注册时间
								</th>
								<th name="level_name" ln="5">
									角色
								</th>
								<th name="level_name" ln="5">
									状态
								</th>
								<th>
									操作
								</th>
							</tr>
						</thead>
						<tbody id="accounts_tb">
							<c:forEach items="${userList.list}" var="sb" varStatus="st">
								<tr class="" id="6" account="aa888">
									<td class="t-l">
										<a href="javascript:void(0)" lower="6" class="bold">${sb.userId}</a>
									</td>
									<td>
										${sb.userName}
									</td>
									<td>
										${sb.userNo}
									</td>
									<td>
										<fmt:formatNumber value="${sb.creditAmt}" pattern="0.##"/>
									</td>
									<td>
										<fmt:formatNumber value="${sb.userBalance}" pattern="0.##"/>
									</td>
									<c:if test="${roleId == 1 }">
										<td>
											<fmt:formatNumber value="${sb.sumBalance }" pattern="0.##"/>
										</td>
									</c:if>
									<td>
										<fmt:formatNumber value="${sb.todayWin == null ? 0 : sb.todayWin }" pattern="0.##"/>
									</td>
									<td>
										<fmt:formatDate value="${sb.createTime}" type="both"
											pattern="yyyy-MM-dd HH:mm:ss" />
									</td>
									<td name="cur_status" ct="1" delst="1">
										<c:if test="${sb.roleId==1}">管理员</c:if>
										<c:if test="${sb.roleId==2}">代理</c:if>
										<c:if test="${sb.roleId==3}">会员</c:if>
									</td>
									<td>
										<c:if test="${sb.userStatus==1}">正常</c:if>
										<c:if test="${sb.userStatus==0}">停押</c:if>
									</td>
									<td class="op">
										<c:if test="${sb.userStatus==1}"><a status="0" href="javascript:void(0)" onclick="limitUser('${sb.userId}');">冻结</a>/</c:if>
										<c:if test="${sb.userStatus==0}"><a status="0" href="javascript:void(0)" onclick="limitUserOk('${sb.userId}');">解冻</a>/</c:if>
										<a href="<%=basePath%>manage/select_list?userId=${sb.userId}" edit="6">查看账户信息</a>/
										<a href="<%=basePath%>manage/cz?userId=${sb.userId}">充值</a>/
										<a href="<%=basePath%>manage/kk?userId=${sb.userId}">扣款</a>/
										<a href="<%=basePath %>manage/double_week?userId=${sb.userId}">两周历史</a>/
										<c:if test="${roleId == 1 }">
											<a href="<%=basePath%>manage/user_list?userId=${sb.userId}">会员列表</a>/
										</c:if>
										<c:if test="${roleId == 2 }">
											<a href="<%=basePath%>user/user_catectic_list?userId=${sb.userId}">今日投注</a>/
										</c:if>
										<c:if test="${roleId == 1 || roleId == 2}">
											<a href="<%=basePath%>manage/auth_password?userId=${sb.userId}">修改密码</a>/
										</c:if>
										<c:if test="${sessionUser.roleId == 1 && sb.roleId == 3 }">
											<a href="javascript:delUser('${sb.userId}');">删除用户</a>/
										</c:if>
									</td>
								</tr>
							</c:forEach>
						</tbody>
					</table>
					${userList.pageStr}
				</div>
			</div>
		</div>	
	</body>
	<script>
	$(function(){
		var i = 0;
	    $('.next').click(function(){
	    	window.location.href = "<%=basePath%>manage/user_list?page=2";
	    });
	    
	    $("#search").click(function(){
	    	var userNo= $("#se_con").val();
	    	window.location.href = "<%=basePath%>manage/user_list?userNo="+userNo;
	    });
	    $(document).bind("contextmenu",function(e){   
		       return false;   
		});
	});
	function limitUser(userId){
			if($.trim(userId) == ''){
				layer.msg("用户id没有获取到");
				return;
			}
			$.ajax({
	            type: "POST",
	            url:"<%=basePath%>manage/limit_user",
	            data:{"userId":userId},
	            error: function(request) {
	                alert("Connection error");
	            },
	            success: function(data) {
	            	if(data.resultCode == '0'){
	            		layer.msg("停押成功");
	            		window.location.reload();
	            	}else{
	            		layer.msg(data.msg);
	            	}
	            }
	        });
	}
	function limitUserOk(userId){
			if($.trim(userId) == ''){
				layer.msg("用户id没有获取到");
				return;
			}
			$.ajax({
	            type: "POST",
	            url:"<%=basePath%>manage/limit_user_ok",
	            data:{"userId":userId},
	            error: function(request) {
	                alert("Connection error");
	            },
	            success: function(data) {
	            	if(data.resultCode == '0'){
	            		layer.msg("解押成功");
	            		window.location.reload();
	            	}else{
	            		layer.msg(data.msg);
	            	}
	            }
	        });
	}
	
	function delUser(userId){
		if($.trim(userId) == ''){
			layer.msg("用户id没有获取到");
			return;
		}
		
		layer.confirm('确定删除该用户？', {
			btn: ['删除', '取消'] //可以无限个按钮
		}, function(index, layero){
			$.ajax({
	            type: "POST",
	            url:"<%=basePath%>user/del_user",
	            data:{"userId":userId},
	            error: function(request) {
	            	layer.msg("Connection error");
	            },
	            success: function(data) {
	            	if(data.resultCode == '0'){
	            		layer.msg("删除成功");
	            		window.location.reload();
	            	}else{
	            		layser.close(index);
	            		layer.msg(data.msg);
	            	}
	            }
	        });
		},function(index,layero){
			layer.close(index);
		});
		
	}
	</script>
</html>